home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xa / CompositeSchemaWindow.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  16.1 KB  |  588 lines

  1. package com.extensibility.xa;
  2.  
  3. import com.extensibility.app.ApplicationPreferences;
  4. import com.extensibility.app.BaseAction;
  5. import com.extensibility.app.BaseWindow;
  6. import com.extensibility.app.CompositeManager;
  7. import com.extensibility.app.DialogFactory;
  8. import com.extensibility.rock.RAction;
  9. import com.extensibility.rock.RTable;
  10. import com.extensibility.xml.BaseDeclaration;
  11. import com.extensibility.xml.InternalPEDeclaration;
  12. import com.extensibility.xml.ParserException;
  13. import com.extensibility.xml.URI;
  14. import java.awt.BorderLayout;
  15. import java.awt.Component;
  16. import java.awt.Window;
  17. import java.awt.event.ActionEvent;
  18. import java.util.Vector;
  19. import javax.swing.JFrame;
  20. import javax.swing.JTextArea;
  21. import javax.swing.JToolBar;
  22.  
  23. public class CompositeSchemaWindow extends SchemaWin {
  24.    String findText;
  25.    String replaceText;
  26.    CompositeManager compositeManager;
  27.    ElementPane elemPane;
  28.    AttributePane attrPane;
  29.    AdvancedPane advPane;
  30.    SourcePane srcPane;
  31.    OverviewPane overPane;
  32.    CommentPane cmtPane;
  33.    ErrorPane errPane;
  34.    FilePane filePane;
  35.    BaseAction parseAction;
  36.    BaseAction expandAction = new 2(this, "edit.item.expand", 69);
  37.    BaseAction showDeclAction = new 3(this, "comment.show.decl");
  38.    BaseAction showDocAction = new 4(this, "comment.show.doc");
  39.    BaseAction overviewAction = new 9(this, "view.item.overview", '0');
  40.    BaseAction elementsAction = new 10(this, "view.item.elements", '1');
  41.    BaseAction attributesAction = new 11(this, "view.item.attributes", '2');
  42.    BaseAction advancedAction = new 12(this, "view.item.advanced", '3');
  43.    BaseAction sourceAction = new 13(this, "view.item.source", '8');
  44.    BaseAction fileAction = new 14(this, "view.item.file");
  45.    BaseAction commentsAction = new 15(this, "view.item.comments", '7');
  46.    boolean focusInProgress;
  47.  
  48.    public CompositeSchemaWindow(SchemaDoc var1) {
  49.       super(var1);
  50.    }
  51.  
  52.    public void initialize(ApplicationPreferences var1) {
  53.       super.initialize(var1);
  54.       ((JFrame)this).getContentPane().setLayout(new BorderLayout());
  55.       ((Component)this).setVisible(false);
  56.       this.compositeManager = new CompositeManager(((JFrame)this).getContentPane(), this.getElemPane());
  57.       JToolBar var2 = ((SchemaWin)this).createToolBar();
  58.       if (var2 != null) {
  59.          ((JFrame)this).getContentPane().add(var2, "North");
  60.       }
  61.  
  62.       ((Window)this).addWindowListener(new 1(this));
  63.       this.elementsAction.setEnabled(false);
  64.       this.showDeclAction.setEnabled(false);
  65.       this.showDocAction.setEnabled(false);
  66.       if (var1 != null) {
  67.          if (var1.getShowLeftPane()) {
  68.             this.showHideLeftPane();
  69.          }
  70.  
  71.          if (var1.getShowBottomPane()) {
  72.             this.showHideCommentPane();
  73.             if (((SchemaDoc)((BaseWindow)this).getDocument()).getComments().hasMoreElements()) {
  74.                this.showSchemaNotes();
  75.             }
  76.          }
  77.       }
  78.  
  79.    }
  80.  
  81.    private ElementPane getElemPane() {
  82.       if (this.elemPane == null) {
  83.          this.elemPane = new ElementPane(((SchemaWin)this).getSchemaDoc());
  84.       }
  85.  
  86.       return this.elemPane;
  87.    }
  88.  
  89.    private AttributePane getAttrPane() {
  90.       if (this.attrPane == null) {
  91.          this.attrPane = new AttributePane(((SchemaWin)this).getSchemaDoc());
  92.       }
  93.  
  94.       return this.attrPane;
  95.    }
  96.  
  97.    private AdvancedPane getAdvPane() {
  98.       if (this.advPane == null) {
  99.          this.advPane = new AdvancedPane(((SchemaWin)this).getSchemaDoc());
  100.       }
  101.  
  102.       return this.advPane;
  103.    }
  104.  
  105.    private OverviewPane getOverPane() {
  106.       if (this.overPane == null) {
  107.          this.overPane = new OverviewPane(((SchemaWin)this).getSchemaDoc());
  108.       }
  109.  
  110.       return this.overPane;
  111.    }
  112.  
  113.    private CommentPane getCmtPane() {
  114.       if (this.cmtPane == null) {
  115.          this.cmtPane = new CommentPane(((SchemaWin)this).getSchemaDoc());
  116.       }
  117.  
  118.       return this.cmtPane;
  119.    }
  120.  
  121.    private SourcePane getSrcPane() {
  122.       if (this.srcPane == null) {
  123.          this.srcPane = new SourcePane(((SchemaWin)this).getSchemaDoc());
  124.       }
  125.  
  126.       return this.srcPane;
  127.    }
  128.  
  129.    private ErrorPane getErrPane() {
  130.       if (this.errPane == null) {
  131.          this.errPane = new ErrorPane(((SchemaWin)this).getSchemaDoc());
  132.       }
  133.  
  134.       return this.errPane;
  135.    }
  136.  
  137.    private FilePane getFilePane() {
  138.       if (this.filePane == null) {
  139.          this.filePane = new FilePane(((SchemaWin)this).getSchemaDoc());
  140.       }
  141.  
  142.       return this.filePane;
  143.    }
  144.  
  145.    public void uriUpdateNotify(URI var1, URI var2) {
  146.       CompositePane[] var3 = this.getAllPanes();
  147.  
  148.       for(int var4 = 0; var4 < var3.length; ++var4) {
  149.          if (var3[var4] != null) {
  150.             var3[var4].uriUpdateNotify(var1, var2);
  151.          }
  152.       }
  153.  
  154.    }
  155.  
  156.    public boolean commitPendingEdits(boolean var1) {
  157.       CompositePane[] var2 = this.getAllPanes();
  158.  
  159.       for(int var3 = 0; var3 < var2.length; ++var3) {
  160.          if (var2[var3] != null) {
  161.             boolean var4 = var2[var3].commitPendingEdits(var1);
  162.             if (!var4) {
  163.                return var4;
  164.             }
  165.          }
  166.       }
  167.  
  168.       return true;
  169.    }
  170.  
  171.    public CompositePane[] getTablePanes() {
  172.       return new CompositePane[]{this.elemPane, this.attrPane, this.advPane};
  173.    }
  174.  
  175.    public CompositePane[] getAllPanes() {
  176.       return new CompositePane[]{this.elemPane, this.attrPane, this.advPane, this.overPane, this.cmtPane, this.srcPane, this.errPane, this.filePane};
  177.    }
  178.  
  179.    public CompositePane[] getMainPanes() {
  180.       return new CompositePane[]{this.elemPane, this.attrPane, this.advPane, this.srcPane, this.filePane};
  181.    }
  182.  
  183.    public DeclTable getTableForClass(Class var1) {
  184.       CompositePane[] var2 = this.getMainPanes();
  185.  
  186.       for(int var3 = 0; var3 < var2.length; ++var3) {
  187.          if (var2[var3] != null) {
  188.             DeclTable var4 = var2[var3].getTableForClass(var1);
  189.             if (var4 != null) {
  190.                return var4;
  191.             }
  192.          }
  193.       }
  194.  
  195.       return null;
  196.    }
  197.  
  198.    public Class getCurrentClass() {
  199.       if (this.compositeManager.getMainPane() == this.elemPane) {
  200.          return Class.forName("com.extensibility.xml.ElementDeclaration");
  201.       } else if (this.compositeManager.getMainPane() == this.attrPane) {
  202.          return Class.forName("com.extensibility.xml.AttributeDeclaration");
  203.       } else if (this.compositeManager.getMainPane() == this.advPane) {
  204.          return this.advPane.getCurrentClass();
  205.       } else {
  206.          return this.compositeManager.getMainPane() == this.srcPane ? Class.forName("com.extensibility.xa.SourcePane") : null;
  207.       }
  208.    }
  209.  
  210.    public String getClassName() {
  211.       return "com.extensibility.xa.CompositeSchemaWindow";
  212.    }
  213.  
  214.    protected JToolBar createToolBar(int var1) {
  215.       JToolBar var2 = super.createToolBar(var1);
  216.       return var2;
  217.    }
  218.  
  219.    public ElementDiagram getCurrentDiagram() {
  220.       return this.getElemPane().getCurrentDiagram();
  221.    }
  222.  
  223.    public JTextArea getSourceText() {
  224.       CompositeManager.Pane var1 = this.compositeManager.getMainPane();
  225.       if (!this.compositeManager.setMainPane(this.getSrcPane())) {
  226.          this.compositeManager.setMainPane(var1);
  227.          return null;
  228.       } else {
  229.          JTextArea var2 = this.getSrcPane().getSourceText();
  230.          this.compositeManager.setMainPane(var1);
  231.          return var2;
  232.       }
  233.    }
  234.  
  235.    protected void fillViewMenu() {
  236.       super.fillViewMenu();
  237.       super.muView.addSeparator();
  238.       super.muView.add(this.getElemPane().getZoomInAction());
  239.       super.muView.add(this.getElemPane().getZoomOutAction());
  240.       super.muView.addAsCheckBox(this.getElemPane().getAutoUpdateDiagramAction());
  241.       super.muView.addSeparator();
  242.       this.createExpandAction().addToMenu(super.muView);
  243.    }
  244.  
  245.    protected DeclTable getCurrentTable() {
  246.       return ((CompositePane)this.compositeManager.getMainPane()).getCurrentTable();
  247.    }
  248.  
  249.    protected RAction createExpandAction() {
  250.       return this.expandAction;
  251.    }
  252.  
  253.    protected RAction createCutAction() {
  254.       return new 5(this, "edit.item.cut", 'X');
  255.    }
  256.  
  257.    protected RAction createCopyAction() {
  258.       return new 6(this, "edit.item.copy", 'C');
  259.    }
  260.  
  261.    protected RAction createPasteAction() {
  262.       return new 7(this, "edit.item.paste", 'V');
  263.    }
  264.  
  265.    protected RAction createClearAction() {
  266.       return new 8(this, "edit.item.clear", 'B');
  267.    }
  268.  
  269.    public boolean find(String var1, boolean var2) {
  270.       CompositeManager.Pane var3 = this.compositeManager.getFocusedPane();
  271.       if (var3 == null) {
  272.          ((Window)this).getToolkit().beep();
  273.          return false;
  274.       } else {
  275.          return var3.find(var1, var2);
  276.       }
  277.    }
  278.  
  279.    public void find() {
  280.       String var1 = DialogFactory.askFind(this, this.findText);
  281.       if (var1 != null) {
  282.          this.findText = var1;
  283.          this.find(this.findText, true);
  284.       }
  285.  
  286.    }
  287.  
  288.    public void findAgain() {
  289.       if (this.findText == null) {
  290.          this.find();
  291.       } else {
  292.          this.find(this.findText, false);
  293.       }
  294.  
  295.    }
  296.  
  297.    public void replace() {
  298.       String[] var1 = DialogFactory.askReplace(this, this.findText, this.replaceText);
  299.       if (var1 != null) {
  300.          this.findText = var1[0];
  301.          this.replaceText = var1[1];
  302.          this.findAgain();
  303.       }
  304.  
  305.    }
  306.  
  307.    public void replaceAgain() {
  308.       if (this.getSelectedText() != null && this.getSelectedText().equals(this.findText) && !this.setSelectedText(this.replaceText)) {
  309.          ((Window)this).getToolkit().beep();
  310.       }
  311.  
  312.       this.findAgain();
  313.    }
  314.  
  315.    public String getSelectedText() {
  316.       CompositeManager.Pane var1 = this.compositeManager.getFocusedPane();
  317.       return var1 == null ? null : var1.getSelectedText();
  318.    }
  319.  
  320.    public boolean setSelectedText(String var1) {
  321.       CompositeManager.Pane var2 = this.compositeManager.getFocusedPane();
  322.       if (var2 == null) {
  323.          ((Window)this).getToolkit().beep();
  324.          return false;
  325.       } else {
  326.          return var2.setSelectedText(var1);
  327.       }
  328.    }
  329.  
  330.    public BaseAction createOverviewAction() {
  331.       return this.overviewAction;
  332.    }
  333.  
  334.    protected BaseAction createElementsAction() {
  335.       return this.elementsAction;
  336.    }
  337.  
  338.    protected BaseAction createAttributesAction() {
  339.       return this.attributesAction;
  340.    }
  341.  
  342.    protected BaseAction createAdvancedAction() {
  343.       return this.advancedAction;
  344.    }
  345.  
  346.    protected BaseAction createSourceAction() {
  347.       return this.sourceAction;
  348.    }
  349.  
  350.    protected BaseAction createFileAction() {
  351.       return this.fileAction;
  352.    }
  353.  
  354.    protected BaseAction createCommentsAction() {
  355.       return this.commentsAction;
  356.    }
  357.  
  358.    public DeclTable getTableForModel(DeclTableModel var1) {
  359.       DeclTable var2 = null;
  360.       if (var1 != null) {
  361.          CompositePane[] var3 = this.getTablePanes();
  362.  
  363.          for(int var4 = 0; var4 < var3.length; ++var4) {
  364.             if (var3[var4] != null) {
  365.                var2 = var3[var4].getTableForModel(var1);
  366.                if (var2 != null) {
  367.                   break;
  368.                }
  369.             }
  370.          }
  371.       }
  372.  
  373.       return var2;
  374.    }
  375.  
  376.    public void showHideLeftPane() {
  377.       if (this.compositeManager.getLeftPane() == null) {
  378.          this.compositeManager.setLeftPane(this.getOverPane());
  379.       }
  380.  
  381.       boolean var1 = this.compositeManager.isLeftPaneVisible();
  382.       this.compositeManager.showHideLeftPane(!var1);
  383.       if (!var1) {
  384.          this.getOverPane().focusDeclaration(((SchemaWin)this).getSchemaDoc().getFocusedDecl());
  385.       }
  386.  
  387.    }
  388.  
  389.    public void showSchemaNotes() {
  390.       this.getCmtPane().setShowMode(2);
  391.    }
  392.  
  393.    public void showHideCommentPane() {
  394.       boolean var1;
  395.       if (this.compositeManager.getBottomPane() != null && !(this.compositeManager.getBottomPane() instanceof ErrorPane)) {
  396.          var1 = this.compositeManager.isBotPaneVisible();
  397.       } else {
  398.          this.compositeManager.setBottomPane(this.getCmtPane());
  399.          var1 = false;
  400.       }
  401.  
  402.       this.compositeManager.showHideBottomPane(!var1);
  403.       this.showDeclAction.setEnabled(!var1);
  404.       this.showDocAction.setEnabled(!var1);
  405.       if (!var1) {
  406.          this.getCmtPane().focusDeclaration(((SchemaWin)this).getSchemaDoc().getFocusedDecl());
  407.       }
  408.  
  409.    }
  410.  
  411.    public void showErrorPane(boolean var1) {
  412.       if (this.compositeManager.getBottomPane() == null || this.compositeManager.getBottomPane() instanceof CommentPane) {
  413.          this.compositeManager.setBottomPane(this.getErrPane());
  414.          this.getErrPane().resetErrors();
  415.          var1 = false;
  416.       }
  417.  
  418.       boolean var2 = this.compositeManager.isBotPaneVisible();
  419.       this.getErrPane().resetErrors();
  420.       if (var1) {
  421.          this.compositeManager.showHideBottomPane(!var2);
  422.       } else {
  423.          this.compositeManager.showHideBottomPane(true);
  424.       }
  425.  
  426.    }
  427.  
  428.    public void hideErrorPane() {
  429.       if (this.compositeManager.getBottomPane() != null) {
  430.          if (!(this.compositeManager.getBottomPane() instanceof CommentPane)) {
  431.             if (this.compositeManager.getBottomPane() instanceof ErrorPane) {
  432.                this.compositeManager.showHideBottomPane(false);
  433.             }
  434.  
  435.          }
  436.       }
  437.    }
  438.  
  439.    public void showFilePane(ParserException var1) {
  440.       if (((SchemaWin)this).getSchemaDoc().isParsedFromFile()) {
  441.          this.fileAction.actionOccurred((ActionEvent)null);
  442.          this.getFilePane().showError(var1);
  443.       } else {
  444.          this.sourceAction.actionOccurred((ActionEvent)null);
  445.          this.getSrcPane().showError(var1);
  446.       }
  447.  
  448.    }
  449.  
  450.    public void setMainPane(CompositeManager.Pane var1) {
  451.       CompositeManager.Pane var2 = this.compositeManager.getMainPane();
  452.       if (this.compositeManager.setMainPane(var1)) {
  453.          this.elementsAction.setEnabled(var1 != this.elemPane);
  454.          this.attributesAction.setEnabled(var1 != this.attrPane);
  455.          this.advancedAction.setEnabled(var1 != this.advPane);
  456.          this.sourceAction.setEnabled(var1 != this.srcPane);
  457.          this.fileAction.setEnabled(var1 != this.filePane);
  458.          this.elemPane.getAutoUpdateDiagramAction().setEnabled(var1 == this.elemPane);
  459.          this.getCmtPane().focusDeclaration(((SchemaWin)this).getSchemaDoc().getFocusedDecl());
  460.       }
  461.    }
  462.  
  463.    public void selectDeclaration(BaseDeclaration var1) {
  464.       CompositePane[] var2 = this.getMainPanes();
  465.       if (this.overPane != null) {
  466.          this.overPane.select(var1);
  467.       }
  468.  
  469.       if (this.compositeManager.getMainPane() != this.advPane) {
  470.          if (var1 instanceof InternalPEDeclaration && ((InternalPEDeclaration)var1).getAttributeGroup() != null) {
  471.             ((SchemaWin)this).editAttrSet(String.valueOf("%").concat(String.valueOf(var1.getName())));
  472.             return;
  473.          }
  474.  
  475.          if (var1 instanceof InternalPEDeclaration && ((InternalPEDeclaration)var1).getContentModel() != null) {
  476.             ((SchemaWin)this).editModel(String.valueOf("%").concat(String.valueOf(var1.getName())));
  477.             return;
  478.          }
  479.  
  480.          if (var1 instanceof InternalPEDeclaration) {
  481.             ((SchemaWin)this).editText(String.valueOf("%").concat(String.valueOf(var1.getName())));
  482.             return;
  483.          }
  484.       }
  485.  
  486.       for(int var3 = 0; var3 < var2.length; ++var3) {
  487.          if (var2[var3] == null) {
  488.             if (this.elemPane == null) {
  489.                var2[var3] = this.getElemPane();
  490.             } else if (this.attrPane == null) {
  491.                var2[var3] = this.getAttrPane();
  492.             } else {
  493.                if (this.advPane != null) {
  494.                   continue;
  495.                }
  496.  
  497.                var2[var3] = this.getAdvPane();
  498.             }
  499.          }
  500.  
  501.          if (var2[var3].select(var1)) {
  502.             this.setMainPane(var2[var3]);
  503.             var2[var3].select(var1);
  504.             break;
  505.          }
  506.       }
  507.  
  508.    }
  509.  
  510.    public BaseAction createGotoAction(BaseDeclaration var1) {
  511.       return new GotoAction(this, var1);
  512.    }
  513.  
  514.    public void declarationFocused(BaseDeclaration var1) {
  515.       if (((SchemaWin)this).getSchemaDoc().getFocusedDecl() != var1) {
  516.          if (!this.focusInProgress) {
  517.             try {
  518.                this.focusInProgress = true;
  519.                super.declarationFocused(var1);
  520.                ((SchemaWin)this).getSchemaDoc().setFocusedDecl(var1);
  521.                CompositePane[] var2 = this.getAllPanes();
  522.  
  523.                for(int var3 = 0; var3 < var2.length; ++var3) {
  524.                   if (var2[var3] != null) {
  525.                      var2[var3].focusDeclaration(var1);
  526.                   }
  527.                }
  528.             } catch (Exception var8) {
  529.                ((Throwable)var8).printStackTrace();
  530.             } finally {
  531.                this.focusInProgress = false;
  532.             }
  533.  
  534.          }
  535.       }
  536.    }
  537.  
  538.    public void diagramUpdated() {
  539.       if (this.elemPane != null) {
  540.          DeclTable var1 = this.elemPane.getCurrentTable();
  541.          if (var1 != null) {
  542.             ((RTable)var1).updateEditor();
  543.          }
  544.  
  545.       }
  546.    }
  547.  
  548.    public void hideConversionErrors() {
  549.       this.compositeManager.setBottomPane(this.getCmtPane());
  550.       this.compositeManager.showHideBottomPane(false);
  551.    }
  552.  
  553.    public void showConversionErrors(Vector var1, URI var2, String var3) {
  554.       this.compositeManager.setBottomPane(new ConversionCheckPane((SchemaDoc)((BaseWindow)this).getDocument(), var1, var2, var3));
  555.       this.compositeManager.showHideBottomPane(true);
  556.    }
  557.  
  558.    // $FF: synthetic method
  559.    static FilePane access$9000571(CompositeSchemaWindow var0) {
  560.       return var0.getFilePane();
  561.    }
  562.  
  563.    // $FF: synthetic method
  564.    static SourcePane access$9000471(CompositeSchemaWindow var0) {
  565.       return var0.getSrcPane();
  566.    }
  567.  
  568.    // $FF: synthetic method
  569.    static CommentPane access$9000171(CompositeSchemaWindow var0) {
  570.       return var0.getCmtPane();
  571.    }
  572.  
  573.    // $FF: synthetic method
  574.    static AdvancedPane access$9000371(CompositeSchemaWindow var0) {
  575.       return var0.getAdvPane();
  576.    }
  577.  
  578.    // $FF: synthetic method
  579.    static AttributePane access$9000271(CompositeSchemaWindow var0) {
  580.       return var0.getAttrPane();
  581.    }
  582.  
  583.    // $FF: synthetic method
  584.    static ElementPane access$9000071(CompositeSchemaWindow var0) {
  585.       return var0.getElemPane();
  586.    }
  587. }
  588.